<?php
namespace App\Http\Controllers\Admin;

use App\Http\Controllers\AdapterWebController;
use Illuminate\Http\Request;
use App\Traits\SmsTrait;

class AliController extends AdapterWebController{
    use SmsTrait;
    public function aliSmsCode(Request $request){
        $phone = $request['phone'];
        $signName = "三咖音乐";
        $template = "SMS_150860113";
        $code = mt_rand(10000,99999);
        $param = json_encode(array(
            "code"=>$code,
        ),JSON_UNESCAPED_UNICODE);
        $data=$this->sendSms($phone,$signName,$template,$param);
        $data = json_decode($data,true);
        if($data['Code'] == "OK"){
            $redis = app("redis");
            $redis->setex($phone,3000,$code);
        }else{
            return false;
        }
    }
    public static function aliSmsAccount($phone){
        $signName = "三咖音乐";
        $template = "SMS_150860245";
        $param = json_encode(array(
            "username"=>$phone,
            "password"=>$phone
        ),JSON_UNESCAPED_UNICODE);
        $data=self::sendSms($phone,$signName,$template,$param);
        return $data;
    }

//    public function ftpLoad(){
//        $conn = ftp_connect('39.105.177.54');
//        $a = ftp_login($conn, 'root', '12345678');
//        var_dump($a);
//        $filelist = ftp_nlist($conn, '.');
//        var_dump($filelist);
//    }
}
